#ifndef _PATCH_H_
#define _PATCH_H_

// patch system, added by regret

#ifndef NO_IPS

#define MAX_NODES 300
#define MAX_ACTIVE_PATCHES 300

class Patcher : public IPatch {
public:
	bool enabled;
	int patchLang;		// description language
	int enforceDep;		// enforce dependency
	wchar_t activePatches[MAX_ACTIVE_PATCHES][MAX_PATH];

	int getCount(unsigned drvIndex);
	int getFilename(wchar_t* pszName, wchar_t* pszRet, int patch_index);
	int getPrevName(wchar_t* pszName, wchar_t* pszGameName, wchar_t* pszPatchName, unsigned drvIndex);
	wchar_t* getDesc(const wchar_t* pszGameName, const wchar_t* pszPatchName);
	wchar_t* getDescByLangcode(FILE* fp, int langcode);
	unsigned getNumActivePatches();
	void exit();

	virtual void apply(unsigned char* base, const char* rom_name, unsigned len);

	Patcher();
	virtual ~Patcher() {}

private:
	void doPatchGame(const char* patchName, const char* romName, unsigned char* base, unsigned base_len);
};

extern Patcher patcher;

// IPS setting dialog
int patchSettingCreate(HWND, unsigned);
int patchSettingInit();
void patchSettingExit();
void loadActivePatches(unsigned drvIndex = ~0U);

#endif

#endif
